package leetcode20211002;

import java.util.HashMap;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: LUYAO
 * Date: 2021-10-02
 * Time: 16:38
 */
public class FindFirstOnlyChar {
    public static void main(String[] args) {

    }
}

class Solution3 {
    public char firstUniqChar(String s) {

        HashMap<Character, Boolean> map = new HashMap<>();
        for(char c : s.toCharArray()){
            map.put(c,!map.containsKey(c));
        }
        for(char c : s.toCharArray()){
            if(map.get(c)){
                return c;
            }
        }
        return ' ';
    }
}
